package com.sy.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.sy.entity.User;

public interface UserDao {

	/**
	 * 查找用户名和密码
	 * 
	 * @param username
	 *            登录用户名
	 * @param password
	 *            密码
	 * @return
	 */
	User findByUsername(String username);

	/**
	 * 注册用户和密码
	 * 
	 * @param username
	 *            用户名
	 * @param password
	 *            密码
	 * @return
	 */
	User registerByUsernameAndPassword(@Param("username") String username, @Param("password") String password);

	@Select("select * from user where id = #{id}")
	User findById(int id);

	@Insert("insert into user (username,password)values(#{username},#{password})")
	void add(User user);

	long addAndGetId(User user);

	List<User> list(@Param("username") String username, @Param("page") int page, @Param("size") int size);

	@Delete("delete from user where id=#{id}")
	int delete(int id);

	@Update("update user set username=#{username},password=#{password} where id=#{id} ")
	int update(User user);

	// List<User>all();

	 

}
